package com.example.qxfw.qxzs.service.impl;

import com.example.qxfw.common.entity.qx.SpecialSrvStation;
import com.example.qxfw.common.entity.zy.Zhishu;
import com.example.qxfw.common.util.FileUtil;
import com.example.qxfw.qxzs.dto.AncillaryDto;
import com.example.qxfw.qxzs.dto.RangeDto;
import com.example.qxfw.qxzs.dto.StationSkDto;
import com.example.qxfw.qxzs.dto.StationYbDto;
import com.example.qxfw.qxzs.service.ZhishuService;
import com.example.qxfw.qxzs.service.ZhishuSetService;
import com.example.qxfw.qxzs.service.ZsybService;
import com.example.qxfw.ybzz.service.WeatherService;
import lombok.Data;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Service;

import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;

@Data
@Service
public class ZsybServiceImpl implements ZsybService {

    @Autowired
    private ZhishuSetService zhishuSetService;

    @Autowired
    private ZhishuService zhishuService;
    @Autowired
    private WeatherService weatherService;


    private AncillaryDto health;
    //平均温
    private double temperature;
    //平均风速/风速
    private double windspeed;
    //平均相对湿度
    private int wetness;
    private int month;        //月份
    //相对湿度对体感温度的修正量
    int Tu;
    //辐射增温系数
    double Ia;
    //风速对体感温度的修正值
    double Tv;
    //预报数据
    private StationYbDto stationYbDto;
    //实况数据
    private StationSkDto stationSkDto;

    private Map<Integer,Double> zhishuMap;


    @Override
    public void calculate(String dateChar,String timeChar,SpecialSrvStation station, StationYbDto stationYbDto, StationSkDto stationSkDto) throws IOException, DocumentException, ParseException {
        this.stationSkDto = stationSkDto;
        this.stationYbDto = stationYbDto;

        zhishuMap = new HashMap<>();

        List<Integer> selectIds = zhishuSetService.getSelectId();
        temperature = (stationYbDto.getFTemperatureLow()+stationYbDto.getFTemperatureHigh())/2.0;//y
        windspeed = (stationYbDto.getFWindSpeedHigh()+ stationYbDto.getFWindSpeedLow()) / 2;
        wetness = (stationYbDto.getFWetnessLow()+stationYbDto.getFWetnessHigh())/2;

        ApplicationHome applicationHome = new ApplicationHome(FileUtil.class);
        String tatuFilepath = applicationHome.getDir().getParentFile().getParentFile().getAbsolutePath() + "\\src\\main\\resources\\file\\zyindex\\TaTu.txt";
        FileInputStream tatuInputSteam = new FileInputStream(tatuFilepath);
        BufferedReader tatuBr = new BufferedReader(new InputStreamReader(tatuInputSteam));

        String str = "";
        if (windspeed < 1)
        {
            windspeed = 1;
        }
        //for (int i = 0; i < windspeed; i++)
            str = tatuBr.readLine();
        System.out.println(str);
        if (str == null)
            str = "";
        Tv = 0.0;
        if (str != "")
        {
            Tv = Double.parseDouble(str);
        }
        Ia = 0.0;
        System.out.println(str);
        str = str.substring(4);
        if (str != "")
        {
            Ia = Double.parseDouble(str);
        }

        if (temperature >= 15)
        {
            if (wetness <= 70) Tu = 0;
            else if (wetness <= 70) Tu = 2;
            else if (wetness <= 90) Tu = 4;
            else Tu = 6;
        }
        else if (temperature >= 10)
        {
            if (wetness <= 70) Tu = 0;
            else if (wetness <= 70) Tu = 1;
            else if (wetness <= 90) Tu = 2;
            else Tu = 3;
        }
        else
        {
            if (wetness <= 70) Tu = 0;
            else if (wetness <= 70) Tu = -1;
            else if (wetness <= 90) Tu = -2;
            else Tu = -3;
        }
        month = new Date().getMonth();
        //医疗指数需要一系列近日参数
        health = new AncillaryDto();
        health.tmax1 = 0;
        health.tmax2 = 0;
        health.tmax3 = 0;
        health.tmax4 = 0;
        health.tmax5 = 0;
        health.tmax6 = 0;
        health.tmin1 = 0;
        health.tmin2 = 0;
        health.tmin3 = 0;
        health.tmin4 = 0;
        health.tmin5 = 0;
        health.tmin6 = 0;
        health.h1 = 0;
        health.h2 = 0;
        health.h3 = 0;
        health.h4 = 0;
        health.h5 = 0;
        health.p1 = 0;
        health.p2 = 0;
        health.p3 = 0;
        health.p4 = 0;
        health.n = 0;
        health.r = 0;
        health.t1 = 0;
        health.t2 = 0;
        health.t3 = 0;
        health.t4 = 0;
        health.t5 = 0;
        health.t6 = 0;
        health.td = 0;


        calculateAll();

        Map<Integer,RangeDto> rangeDtoMap = new HashMap<>();

        //读取等级
        SAXReader saxReader = new SAXReader();
        Document document = saxReader.read("src\\main\\resources\\file\\zyindex\\Range.xml");
        Element root = document.getRootElement();
        Iterator<Element> elementIterator = root.elementIterator();

        int index=0;
        while (elementIterator.hasNext()){
//            System.out.println(index);
            Element rangesNode = elementIterator.next();
            int totalLevel = Integer.parseInt(rangesNode.attributeValue("totalLevel"));
            System.out.println(rangesNode.getName()+":"+rangesNode.attributeValue("name")+rangesNode.attributeValue("totalLevel"));
            if (totalLevel == 0){
                RangeDto rangeDto = new RangeDto(-10000,0,0,"无","无");
                rangeDtoMap.put(index,rangeDto);
                index++;
                continue;
            }
            if (rangesNode.getName().equals("index29")){
                Calendar calendar = Calendar.getInstance();
                // 获取当前月
                int month = calendar.get(Calendar.MONTH) + 1;
                if (month>=2&&month<5){
                    rangesNode = rangesNode.element("spring");
                } else if (month>=5&&month<8){
                    rangesNode = rangesNode.element("summer");
                } else if (month>=8&&month<10){
                    rangesNode = rangesNode.element("autumn");
                } else {
                    rangesNode = rangesNode.element("winter");
                }

            }
            System.out.println(index);
            Iterator<Element> rangeNodeIterator = rangesNode.elementIterator();
            double value = zhishuMap.get(index);
            System.out.println(index+":"+value);
            while (rangeNodeIterator.hasNext()) {
                Element rangeNode = rangeNodeIterator.next();
                double value0 = Double.parseDouble(rangeNode.elementText("value0"));
                double value1 = Double.parseDouble(rangeNode.elementText("value1"));
                String level = rangeNode.elementText("level");
                String description = rangeNode.elementText("description");

                if (value>value0 && value<value1){
                    for (Integer selectId : selectIds) {
                        if (selectId == index){
                            RangeDto rangeDto = new RangeDto(value,value0,value1,level,description);
                            rangeDtoMap.put(index,rangeDto);
                            break;
                        }
                    }
                    if (!rangeDtoMap.containsKey(index)){
                        RangeDto rangeDto = new RangeDto(-10000,0,0,"无","无");
                        rangeDtoMap.put(index,rangeDto);
                    }
                    break;
                }
            }
            if (!rangeDtoMap.containsKey(index)){
                RangeDto rangeDto = new RangeDto(-10000,0,0,"无","无");
                rangeDtoMap.put(index,rangeDto);
            }
            index++;
        }

        //存储数据库
        Zhishu zhishu = new Zhishu();
        zhishu.setCityid(station.getStationid());
        zhishu.setCityname(station.getStationname());
        SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        zhishu.setDatechar(ft.parse(dateChar));
        zhishu.setTimechar(timeChar);
        zhishu.setLongitude(station.getLongitude());
        zhishu.setLatitude(station.getLatitude());

        //设置初试参数为空
        // 防晒指数
        zhishu.setFs(0f);
        zhishu.setFsgrade("无");
        zhishu.setFstext("无");
        //霉变指数
        zhishu.setMb(0f);
        zhishu.setMbgrade("无");
        zhishu.setMbtext("无");
        //着装指数
        zhishu.setZz(0f);
        zhishu.setZzgrade("无");
        zhishu.setZztext("无");
        //晾晒指数
        zhishu.setLs(0f);
        zhishu.setLsgrade("无");
        zhishu.setLstext("无");
        //冷饮指数
        zhishu.setLy(0f);
        zhishu.setLygrade("无");
        zhishu.setLytext("无");
        //热岛指数
        zhishu.setRd(0f);
        zhishu.setRdgrade("无");
        zhishu.setRdtext("无");
        //人体舒适度指数
        zhishu.setSs(0f);
        zhishu.setSsgrade("无");
        zhishu.setSsgrade("无");
        //紫外线指数
        zhishu.setZw(0f);
        zhishu.setZwgrade("无");
        zhishu.setZwtext("无");
        //啤酒指数
        zhishu.setPj(0f);
        zhishu.setPjgrade("无");
        zhishu.setPjtext("无");
        //空调指数
        zhishu.setKt(0f);
        zhishu.setKtgrade("无");
        zhishu.setKttext("无");
        //体感指数
        zhishu.setTg(0f);
        zhishu.setTggrade("无");
        zhishu.setTgtext("无");
        //雨伞指数
        zhishu.setYs(0f);
        zhishu.setYsgrade("无");
        zhishu.setYstext("无");
        //污染物扩散指数
        zhishu.setWr(0f);
        zhishu.setWrgrade("无");
        zhishu.setWrtext("无");
        //百叶箱指数
        zhishu.setByx(0f);
        zhishu.setByxgrade("无");
        zhishu.setByxtext("无");
        //中暑指数
        zhishu.setZs(0f);
        zhishu.setZsgrade("无");
        zhishu.setZstext("无");
        //感冒指数
        zhishu.setGm(0f);
        zhishu.setGmgrade("无");
        zhishu.setGmtext("无");
        //肺炎指数
        zhishu.setFy(0f);
        zhishu.setFygrade("无");
        zhishu.setFytext("无");
        //上呼吸道感染指数
        zhishu.setShx(0f);
        zhishu.setShxgrade("无");
        zhishu.setShxtext("无");
        //下呼吸道感染指数
        zhishu.setXhx(0f);
        zhishu.setShxgrade("无");
        zhishu.setShxtext("无");
        //哮喘指数
        zhishu.setXc(0f);
        zhishu.setXcgrade("无");
        zhishu.setXctext("无");
        //脑溢血指数
        zhishu.setNyx(0f);
        zhishu.setNyxtext("无");
        zhishu.setNyxtext("无");
        //脑梗赛指数
        zhishu.setNgs(0f);
        zhishu.setNgsgrade("无");
        zhishu.setNgstext("无");
        //冠心病指数
        zhishu.setGxb(0f);
        zhishu.setGxbgrade("无");
        zhishu.setGxbtext("无");
        //心肌梗塞指数
        zhishu.setXjgs(0f);
        zhishu.setXjgsgrade("无");
        zhishu.setXjgstext("无");
        //高血压指数
        zhishu.setGxy(0f);
        zhishu.setGxygrade("无");
        zhishu.setGxytext("无");
        //旅游指数
        zhishu.setLyou(0f);
        zhishu.setLyougrade("无");
        zhishu.setLyoutext("无");
        //垂钓指数
        zhishu.setCd(0f);
        zhishu.setCdgrade("无");
        zhishu.setCdtext("无");
        //交通指数
        zhishu.setJt(0f);
        zhishu.setJtgrade("无");
        zhishu.setJttext("无");
        //用电指数
        zhishu.setYd(0f);
        zhishu.setYdgrade("无");
        zhishu.setYdtext("无");
        //火险指数
        zhishu.setHx(0f);
        zhishu.setHxgrade("无");
        zhishu.setHxtext("无");
        //晨练指数
        zhishu.setCl(0f);
        zhishu.setClgrade("无");
        zhishu.setCltext("无");

        System.out.println("rangeDtoMap:size"+rangeDtoMap.size());
        Set<Map.Entry<Integer, RangeDto>> entries = rangeDtoMap.entrySet();
        for (Map.Entry<Integer, RangeDto> entry : entries) {
            int zhishuIndex = entry.getKey();
            RangeDto rangeDto = entry.getValue();
            System.out.println(zhishuIndex);
            System.out.println(rangeDto.toString());
            switch (zhishuIndex){
                case 0:
                    //防晒指数
                    zhishu.setFs((float) rangeDto.getValue());
                    zhishu.setFsgrade(rangeDto.getLevel());
                    zhishu.setFstext(rangeDto.getDescription());
                case 1:
                    //霉变指数
                    zhishu.setMb((float) rangeDto.getValue());
                    zhishu.setMbgrade(rangeDto.getLevel());
                    zhishu.setMbtext(rangeDto.getDescription());
                    break;
                case 2:
                    //着装指数
                    zhishu.setZz((float) rangeDto.getValue());
                    zhishu.setZzgrade(rangeDto.getLevel());
                    zhishu.setZztext(rangeDto.getDescription());
                    break;
                case 3:
                    //晾晒指数
                    zhishu.setLs((float) rangeDto.getValue());
                    zhishu.setLsgrade(rangeDto.getLevel());
                    zhishu.setLstext(rangeDto.getDescription());
                    break;
                case 4:
                    //冷饮指数
                    zhishu.setLy((float) rangeDto.getValue());
                    zhishu.setLygrade(rangeDto.getLevel());
                    zhishu.setLytext(rangeDto.getDescription());
                    break;
                case 5:
                    //热岛指数
                    zhishu.setRd((float) rangeDto.getValue());
                    zhishu.setRdgrade(rangeDto.getLevel());
                    zhishu.setRdtext(rangeDto.getDescription());
                    break;
                case 6:
                    //人体舒适度指数
                    zhishu.setSs((float) rangeDto.getValue());
                    zhishu.setSsgrade(rangeDto.getLevel());
                    zhishu.setSsgrade(rangeDto.getLevel());
                    break;
                case 7:
                    //紫外线指数
                    zhishu.setZw((float) rangeDto.getValue());
                    zhishu.setZwgrade(rangeDto.getLevel());
                    zhishu.setZwtext(rangeDto.getDescription());
                    break;
                case 8:
                    //啤酒指数
                    zhishu.setPj((float) rangeDto.getValue());
                    zhishu.setPjgrade(rangeDto.getLevel());
                    zhishu.setPjtext(rangeDto.getDescription());
                    break;
                case 9:
                    //空调指数
                    zhishu.setKt((float) rangeDto.getValue());
                    zhishu.setKtgrade(rangeDto.getLevel());
                    zhishu.setKttext(rangeDto.getDescription());
                    break;
                case 10:
                    //体感指数
                    zhishu.setTg((float) rangeDto.getValue());
                    zhishu.setTggrade(rangeDto.getLevel());
                    zhishu.setTgtext(rangeDto.getDescription());
                    break;
                case 11:
                    //雨伞指数
                    zhishu.setYs((float) rangeDto.getValue());
                    zhishu.setYsgrade(rangeDto.getLevel());
                    zhishu.setYstext(rangeDto.getDescription());
                    break;
                case 12:
                    //污染物扩散指数
                    zhishu.setWr((float) rangeDto.getValue());
                    zhishu.setWrgrade(rangeDto.getLevel());
                    zhishu.setWrtext(rangeDto.getDescription());
                    break;
                case 13:
                    //百叶箱指数
                    zhishu.setByx((float) rangeDto.getValue());
                    zhishu.setByxgrade(rangeDto.getLevel());
                    zhishu.setByxtext(rangeDto.getDescription());
                    break;
                case 14:
                    //中暑指数
                    zhishu.setZs((float) rangeDto.getValue());
                    zhishu.setZsgrade(rangeDto.getLevel());
                    zhishu.setZstext(rangeDto.getDescription());
                    break;
                case 15:
                    //感冒指数
                    zhishu.setGm((float) rangeDto.getValue());
                    zhishu.setGmgrade(rangeDto.getLevel());
                    zhishu.setGmtext(rangeDto.getDescription());
                    break;
                case 16:
                    //肺炎指数
                    zhishu.setFy((float) rangeDto.getValue());
                    zhishu.setFygrade(rangeDto.getLevel());
                    zhishu.setFytext(rangeDto.getDescription());
                    break;
                case 17:
                    //上呼吸道感染指数
                    zhishu.setShx((float) rangeDto.getValue());
                    zhishu.setShxgrade(rangeDto.getLevel());
                    zhishu.setShxtext(rangeDto.getDescription());
                    break;
                case 18:
                    //下呼吸道感染指数
                    zhishu.setXhx((float) rangeDto.getValue());
                    zhishu.setShxgrade(rangeDto.getLevel());
                    zhishu.setShxtext(rangeDto.getDescription());
                    break;
                case 19:
                    //哮喘指数
                    zhishu.setXc((float) rangeDto.getValue());
                    zhishu.setXcgrade(rangeDto.getLevel());
                    zhishu.setXctext(rangeDto.getDescription());
                    break;
                case 20:
                    //脑溢血指数
                    zhishu.setNyx((float) rangeDto.getValue());
                    zhishu.setNyxtext(rangeDto.getLevel());
                    zhishu.setNyxtext(rangeDto.getDescription());
                    break;
                case 21:
                    //脑梗赛指数
                    zhishu.setNgs((float) rangeDto.getValue());
                    zhishu.setNgsgrade(rangeDto.getLevel());
                    zhishu.setNgstext(rangeDto.getDescription());
                    break;
                case 22:
                    //冠心病指数
                    zhishu.setGxb((float) rangeDto.getValue());
                    zhishu.setGxbgrade(rangeDto.getLevel());
                    zhishu.setGxbtext(rangeDto.getDescription());
                    break;
                case 23:
                    //心肌梗塞指数
                    zhishu.setXjgs((float) rangeDto.getValue());
                    zhishu.setXjgsgrade(rangeDto.getLevel());
                    zhishu.setXjgstext(rangeDto.getDescription());
                    break;
                case 24:
                    //高血压指数
                    zhishu.setGxy((float) rangeDto.getValue());
                    zhishu.setGxygrade(rangeDto.getLevel());
                    zhishu.setGxytext(rangeDto.getDescription());
                    break;
                case 25:
                    //旅游指数
                    zhishu.setLyou((float) rangeDto.getValue());
                    zhishu.setLyougrade(rangeDto.getLevel());
                    zhishu.setLyoutext(rangeDto.getDescription());
                    break;
                case 26:
                    //垂钓指数
                    zhishu.setCd((float) rangeDto.getValue());
                    zhishu.setCdgrade(rangeDto.getLevel());
                    zhishu.setCdtext(rangeDto.getDescription());
                    break;
                case 27:
                    //交通指数
                    zhishu.setJt((float) rangeDto.getValue());
                    zhishu.setJtgrade(rangeDto.getLevel());
                    zhishu.setJttext(rangeDto.getDescription());
                    break;
                case 28:
                    //用电指数
                    zhishu.setYd((float) rangeDto.getValue());
                    zhishu.setYdgrade(rangeDto.getLevel());
                    zhishu.setYdtext(rangeDto.getDescription());
                    break;
                case 29:
                    //火险指数
                    zhishu.setHx((float) rangeDto.getValue());
                    zhishu.setHxgrade(rangeDto.getLevel());
                    zhishu.setHxtext(rangeDto.getDescription());
                    break;
                case 30:
                    //晨练指数
                    zhishu.setCl((float) rangeDto.getValue());
                    zhishu.setClgrade(rangeDto.getLevel());
                    zhishu.setCltext(rangeDto.getDescription());
                    break;
            }

        }

        Zhishu zhishu1 = new Zhishu();
        zhishu1.setCityid(station.getStationid());
        zhishu1.setCityname(station.getStationname());
        zhishu1.setDatechar(ft.parse(dateChar));
        zhishu1.setTimechar(timeChar);
        zhishu1.setLongitude(station.getLongitude());
        zhishu1.setLatitude(station.getLatitude());
        //指数添加之前先删除
        zhishuService.deleteZhishu(zhishu1);
        //保存指数
        zhishuService.saveZhishu(zhishu);
    }



    /**
     * 计算所有指数
     * @throws IOException
     */
    private void calculateAll() throws IOException {
        calculate1();
        calculate2();
        calculate3();
        calculate4();
        calculate5();
        calculate6();
        calculate7();
        calculate8();
        calculate9();
        calculate10();
        calculate11();
        calculate12();
        calculate13();
        calculate14();
        calculate15();
        calculate16();
        calculate17();
        calculate18();
        calculate19();
        calculate20();
        calculate21();
        calculate22();
        calculate23();
        calculate24();
        calculate25();
        calculate26();
        calculate27();
        calculate28();
        calculate29();
        calculate30();
        calculate0();
        Set<Map.Entry<Integer, Double>> entries = zhishuMap.entrySet();

        for (Map.Entry<Integer, Double> entry : entries) {
            System.out.println("指数=》index："+entry.getKey()+"   value:"+entry.getValue());

        }
    }


    /**
     * 计算霉变指数
     * @return
     */
    private void calculate1(){
        double temp1 = wetness - 70;
        double temp2 = temperature - 20.0;
        if (temp1 <= 0 || temp2 <= 0)
            zhishuMap.put(1,0.0);
        else
            zhishuMap.put(1,temp1 * temp2);
    }

    /**
     * 计算着装指数
     * @return
     */
    private void calculate2(){
        double temp;
        if (month > 5 && month < 9)
            temp = ((33.0 - temperature) / 16.0);
        else
            temp = ((33.0 - stationYbDto.getFTemperatureLow()) / 12.84);
        zhishuMap.put(2,temp);
    }

    /**
     * 晾晒,等级判断
     * @return
     */
    private void calculate3(){
        double value;
        if (month == 12 || month == 1 || month == 2)
        {
            value =  3.931 + 0.1174 * stationYbDto.getFTemperatureHigh() - 0.07428 * temperature
                    - 0.04388 * wetness + 0.1568 * windspeed;
        }
        else if (month >= 5 && month <= 9)
        {
            value = 7.408 + 0.1416 * stationYbDto.getFTemperatureHigh() + 0.1487 * temperature
                    - 0.1322 * wetness - 0.1677 * stationYbDto.getFCloudAll() + 0.7315 * windspeed;
        }
        else
        {
            value = 5.844 + 0.135 * stationYbDto.getFTemperatureHigh() - 0.07506 * temperature
                    - 0.075 * stationYbDto.getFCloudAll() + 0.3174 * windspeed;
        }
        zhishuMap.put(3,value);
    }

    /**
     * 冷饮指数
     * @return
     */
    private void calculate4(){
        double val;
        if (month >= 4 && month <= 10)
        {
            val = temperature + 0.42 * 0.6 * (1 - 0.09 * stationYbDto.getFCloudAll()) * Ia + Tu - Tv;
            if (val < 20)
                val = -10000;
        }
        else
        {
           val = -10000;
        }
        zhishuMap.put(4,val);
    }

    /**
     * 城市热岛指数，ifx参数,存储前一天的ifx
     */
    private void calculate5(){
        double value;
        int ifx;
        int preifx = 2;//前一天的ifx
        if (stationYbDto.getFWindDirection1() != stationYbDto.getFWindDirection2())
            ifx = 0;
        else if (stationYbDto.getFWindDirection1() == 0 && preifx < 0)
            ifx = 0;
        else if (stationYbDto.getFWindDirection1() == 0)
            ifx = preifx + 1;
        else
            ifx = preifx + 1;

        if (ifx > 2) ifx = 2;
        if (ifx < -3) ifx = -3;

        value = 0.12 * ifx - 0.36 * windspeed - 0.13 * stationYbDto.getFTemperatureLow() + 5.87;
        zhishuMap.put(5,value);
    }

    /**
     * 人体舒适度指数
     */
    private void calculate6(){
        double value = (33 - stationYbDto.getFTemperatureHigh()) * (19.9 - windspeed);
        zhishuMap.put(6,value);
    }

    /**
     * 紫外线指数
     * @throws IOException
     */
    private void calculate7() throws IOException {
        ApplicationHome applicationHome = new ApplicationHome(FileUtil.class);
        String uvFilepath = applicationHome.getDir().getParentFile().getParentFile().getAbsolutePath() + "\\src\\main\\resources\\file\\zyindex\\紫外线.txt";
        FileInputStream uvInputSteam = new FileInputStream(uvFilepath);
        BufferedReader uvBr = new BufferedReader(new InputStreamReader(uvInputSteam));
        int line = 0;
        int i = 0;
        String str = "";
        switch (month)
        {
            case 2:
            case 3:
                line = 2; break;
            case 4:
            case 5:
            case 6:
                line = 14; break;
            case 7:
            case 8:
                line = 26; break;
            case 9:
            case 10:
                line = 38; break;
            case 11:
            case 12:
            case 1:
                line = 50; break;
        }
        for (i = 0; i < line; i++)
        {
            str = uvBr.readLine();
        }
        for (i = 0; i < stationYbDto.getFCloudAll(); i++)
        {
            str = uvBr.readLine();
        }
        str = str.replaceAll("\t", ",");
        String[] strtemp = str.split(",");
        for (i = 0; i < stationYbDto.getFCloudLow(); i++)
        {
            if (strtemp[i] != "")
            {
                zhishuMap.put(7,Double.parseDouble(strtemp[i]));
            }
        }
        zhishuMap.put(7,0.0);
    }

    /**
     * 啤酒指数
     */
    private void calculate8() throws IOException {
        double Tave, Fave, Qave, Nave;	//多年平均情况
        double Tmax, Fmax, Qmax, Nmax;	//多年最高值
        double Tmin, Fmin, Qmin, Nmin;	//多年最低值
        Tave = 35; Tmax = 39; Tmin = 30;
        Fave = 4; Fmax = 6; Fmin = 1;
        Qave = 60; Qmax = 90; Qmin = 5;
        Nave = 4; Nmax = 9; Nmin = 1;

        ApplicationHome applicationHome = new ApplicationHome(FileUtil.class);
        String filepath = applicationHome.getDir().getParentFile().getParentFile().getAbsolutePath() + "\\src\\main\\resources\\file\\zyindex\\啤酒指数.txt";
        FileInputStream inputSteam = new FileInputStream(filepath);
        BufferedReader br = new BufferedReader(new InputStreamReader(inputSteam));

        br.readLine(); Tave = Double.parseDouble(br.readLine().trim());
        br.readLine(); Tmax = Double.parseDouble(br.readLine().trim());
        br.readLine(); Tmin = Double.parseDouble(br.readLine().trim());
        br.readLine(); Fave = Double.parseDouble(br.readLine().trim());
        br.readLine(); Fmax = Double.parseDouble(br.readLine().trim());
        br.readLine(); Fmin = Double.parseDouble(br.readLine().trim());
        br.readLine(); Qave = Double.parseDouble(br.readLine().trim());
        br.readLine(); Qmax = Double.parseDouble(br.readLine().trim());
        br.readLine(); Qmin = Double.parseDouble(br.readLine().trim());
        br.readLine(); Nave = Double.parseDouble(br.readLine().trim());
        br.readLine(); Nmax = Double.parseDouble(br.readLine().trim());
        br.readLine(); Nmin = Double.parseDouble(br.readLine().trim());

        double value = 2 * 0.75 * (temperature - Tave) / (Tmax - Tmin) + 0.10 * (windspeed - Fave) / (Fmax - Fmin)
                + 0.10 * (wetness - Qave) / (Qmax - Qmin) + 0.05 * (stationYbDto.getFCloudAll() - Nave) / (Nmax - Nmin);
        zhishuMap.put(8,value);
    }

    /**
     * 空调开机指数
     */
    private void calculate9(){
        Double value = zhishuMap.get(6);
        zhishuMap.put(9,value);
    }

    /**
     * 体感温度
     */
    private void calculate10(){
        double Tj = 0;
        double value = temperature + 0.42 * 0.6 * (1 - 0.09 * stationYbDto.getFCloudAll()) * Ia + Tu - Tv - Tj;
        zhishuMap.put(10,value);
    }

    /**
     * 雨伞指数
     */
    private void calculate11(){
        zhishuMap.put(11,(double) stationYbDto.getFPrecipitationrate());
    }

    /**
     * 空气污染气象条件,很麻烦,参数需要确认，等级的值域没有给
     */
    private void calculate12(){
        zhishuMap.put(12,0.0);
    }

    /**
     * 百叶箱外温度预报
     */
    private void calculate13(){
        double value;
        if (month >= 6 && month <= 8)
        {
            value = -0.329 + 1.1936 * stationYbDto.getFTemperatureHigh();
        }
        else
        {
            value = -10000;
        }
        zhishuMap.put(13,value);
    }

    /**
     * 中暑指数,需要昨日的资料
     */
    private void calculate14(){
        double value;
        if (month >= 5 && month <= 9)
        {
            double t_35;			//当天的需要存储
            double t_35_0 = 2;	//历史纪录,为前一天的t_35,注意5月1日的处理

            health.t1 = 37;		//近3日的平均温，在InitPrmt中初始化，此处应直接调用，完成了后删

            if (stationYbDto.getFTemperatureHigh() >= 35)
                t_35 = t_35_0 + stationYbDto.getFTemperatureHigh() - 35;
            else
                t_35 = 0;

            value = -12.15 + 0.42 * health.t1 + 0.33 * t_35;
        }
        else
            value = -10000;
        zhishuMap.put(14,value);
    }

    /**
     * 感冒指数
     */
    private void calculate15(){
        double value;
        double t1 = (double)(stationSkDto.getTTemperature() - temperature);
        double t2 = (double)(stationSkDto.getTTemperatureHigh() - stationSkDto.getTTemperatureLow());
        int n;
        if (stationYbDto.getFWindDirection2() == 1)
            n = 1;
        else
            n = -1;

        //计算公式
        value = (t1 * 4 + t2 * 0.2 + 10 * n) / 100.00;
        zhishuMap.put(15,value);
    }

    /**
     *肺炎，参数不明
     */
    private void calculate16(){
        double value;

        if (month >= 3 && month <= 5)
        {
        }
        else if (month >= 6 && month <= 8)
        {
        }
        else if (month >= 9 && month <= 11)
        {
        }
        else
        {
        }
        value = 5;//完成了删
        zhishuMap.put(16,value);
    }

    /**
     * 上呼吸道
     */
    private void calculate17(){
        double value;
        double sg;

        if (month >= 3 && month <= 5)
        {
            sg = -0.05826 + 0.01823 * health.t2 - 0.00333 * health.h1;
            value = ((sg + 1) * 3.68 - 4.1) / 4.1;
        }
        else if (month >= 6 && month <= 8)
        {
            sg = -1.70476 + 0.05454 * health.tmin2 - 0.01813 * health.tmin6 + 0.00662 * health.h1 - 0.02605 * health.n;
            value = ((sg + 1) * 6.57 - 4.1) / 4.1;

        }
        else if (month >= 9 && month <= 11)
        {
            sg = 0.10494 - 0.20096 * health.tmin2 + 0.23096 * health.t2 - 0.14228 * health.td - 0.03249 * health.n;
            value = ((sg + 1) * 2.98 - 4.1) / 4.1;
        }
        else
        {
            sg = -0.053847 - 0.036266 * health.tmin1 + 0.011521 * health.tmin6 - 0.0197 * health.t3 + 0.005131 * health.h1 - 0.036346 * health.n;
            value = ((sg + 1) * 3.14 - 4.1) / 4.1;
        }
        zhishuMap.put(17,value);
    }

    /**
     * 下呼吸道
     */
    private void calculate18(){

        double value;
        double xg;

        if (month >= 3 && month <= 5)
        {
            xg = 0.59672 + 0.00629 * health.tmin6 - 0.01771 * health.t2 - 0.00379 * health.h1 + 0.00211 * health.h5 - 0.00436 * health.p3 - 0.00209 * health.r;
            value = ((xg + 1) * 7.31 - 6.81) / 6.81;
        }
        else if (month >= 6 && month <= 8)
        {
            xg = 1.71104 - 0.05865 * health.tmax2 + 0.03837 * health.t2 - 0.01144 * health.h1 - 0.01141 * health.p1;
            value = ((xg + 1) * 5.53 - 6.81) / 6.81;
        }
        else if (month >= 9 && month <= 11)
        {
            xg = 0.61277 + 0.10677 * health.tmax1 + 0.00999 * health.tmax3 + 0.00812 * health.tmin4 + 0.01269 * health.tmin5 + 0.01306 * health.tmin6 - 0.12164 * health.t1 - 0.08327 * health.td - 0.0245 * health.n - 0.00162 * health.r;
            value = ((xg + 1) * 5.05 - 6.81) / 6.81;
        }
        else
        {
            xg = 0.45985 + 0.12686 * health.tmax2 + 0.1004 * health.tmin2 + 0.01216 * health.tmin6 - 0.27902 * health.t2 + 0.01513 * health.t5 - 0.0154 * health.p1;
            value = ((xg + 1) * 9.34 - 6.81) / 6.81;
        }
        zhishuMap.put(18,value);
    }

    /**
     * 哮喘
     */
    private void calculate19(){
        double value;
        double xc;

        if (month >= 3 && month <= 5)
        {
            xc = -0.08267 + 0.00627 * health.tmin1;
            value = ((xc + 1) * 1.16 - 1.22) / 1.22;
        }
        else if (month >= 6 && month <= 8)
        {
            xc = 1.91279 - 0.02364 * health.tmax2 - 0.01596 * health.h1 + 0.04023 * health.p1;
            value = ((xc + 1) * 0.88 - 1.22) / 1.22;
        }
        else if (month >= 9 && month <= 11)
        {
            xc = -0.35706 + 0.08011 * health.tmax2 - 0.09633 * health.t2 + 0.04708 * health.n;
            value = ((xc + 1) * 1.59 - 1.22) / 1.22;
        }
        else
        {
            xc = 0.16083 + 0.01636 * health.tmin6 - 0.0258 * health.t1;
            value = ((xc + 1) * 1.27 - 1.22) / 1.22;
        }
        zhishuMap.put(19,value);
    }

    /**
     * 脑溢血
     */
    private void calculate20(){
        double nyx;
        double value;

        if (month >= 3 && month <= 5)
        {
            nyx = -0.41047 - 0.01459 * health.tmax2 + 0.00791 * health.h1 - 0.00276 * health.h5 + 0.01794 * health.n;
            value = ((nyx + 1) * 1.61 - 1.64) / 1.64;
        }
        else if (month >= 6 && month <= 8)
        {
            nyx = -0.5304 - 0.09506 * health.tmin2 + 0.0678 * health.t1 + 0.01228 * health.h1 + 0.02219 * health.p1 + 0.0156 * health.p2;
            value = ((nyx + 1) * 1.29 - 1.64) / 1.64;
        }
        else if (month >= 9 && month <= 11)
        {
            nyx = -0.19204 - 0.01436 * health.t6 + 0.00711 * health.p1 + 0.01458 * health.n - 0.00301 * health.r;
            value = ((nyx + 1) * 1.74 - 1.64) / 1.64;
        }
        else
        {
            nyx = -0.11199 - 0.01984 * health.tmin2 + 0.00808 * health.p1;
            value = ((nyx + 1) * 1.94 - 1.64) / 1.64;
        }
        zhishuMap.put(20,value);
    }

    /**
     * 脑梗塞
     */
    private void calculate21(){
        double ngs;
        double value;

        if (month >= 3 && month <= 5)
        {
            ngs = 0.08037 - 0.00445 * health.tmin2 - 0.00224 * health.r;
            value = ((ngs + 1) * 2.56 - 2.64) / 2.64;
        }
        else if (month >= 6 && month <= 8)
        {
            ngs = -0.58129 + 0.02288 * health.tmin3 + 0.01979 * health.tmin4 + 0.01669 * health.tmin5 + 0.02251 * health.tmin6 + 0.01693 * health.t2 - 0.0235 * health.p1 + 0.01227 * health.p4 + 0.02259 * health.n;
            value = ((ngs + 1) * 2.94 - 2.64) / 2.64;

        }
        else if (month >= 9 && month <= 11)
        {
            ngs = -0.18364 + 0.01777 * health.tmin2 - 0.00536 * health.h1 + 0.01174 * health.p1 + 0.02322 * health.n - 0.00187 * health.r;
            value = ((ngs + 1) * 2.65 - 2.64) / 2.64;

        }
        else
        {
            ngs = -0.33192 + 0.02924 * health.tmax2 + 0.00947 * health.tmax3 + 0.0042 * health.r;
            value = ((ngs + 1) * 2.56 - 2.64) / 2.64;

        }
        zhishuMap.put(21,value);
    }

    /**
     * 冠心病
     */
    private void calculate22(){
        double gxb;
        double value;

        if (month >= 3 && month <= 5)
        {
            gxb = 0.188278 - 0.014182 * health.tmin2 - 0.001707 * health.h3;
            value = ((gxb + 1) * 2.26 - 2.26) / 2.26;
        }
        else if (month >= 6 && month <= 8)
        {
            gxb = -0.69086 + 0.02697 * health.tmin2 + 0.00095 * health.r;
            value = ((gxb + 1) * 1.93 - 2.26) / 2.26;
        }
        else if (month >= 9 && month <= 11)
        {
            gxb = -0.79421 + 0.02144 * health.tmin2 + 0.0228 * health.p1 - 0.00833 * health.p4 + 0.01725 * health.n;
            value = ((gxb + 1) * 2.45 - 2.26) / 2.26;
        }
        else
        {
            gxb = 0.217218 + 0.012412 * health.t4 - 0.002913 * health.h1 - 0.005687 * health.t6;
            value = ((gxb + 1) * 2.46 - 2.26) / 2.26;
        }
        zhishuMap.put(22,value);
    }

    /**
     * 心肌梗塞
     */
    private void calculate23(){
        double gxb;
        double value;

        if (month >= 3 && month <= 5)
        {
            gxb = 0.188278 - 0.014182 * health.tmin2 - 0.001707 * health.h3;
            value = ((gxb + 1) * 2.26 - 2.26) / 2.26;
        }
        else if (month >= 6 && month <= 8)
        {
            gxb = -0.69086 + 0.02697 * health.tmin2 + 0.00095 * health.r;
            value = ((gxb + 1) * 1.93 - 2.26) / 2.26;
        }
        else if (month >= 9 && month <= 11)
        {
            gxb = -0.79421 + 0.02144 * health.tmin2 + 0.0228 * health.p1 - 0.00833 * health.p4 + 0.01725 * health.n;
            value = ((gxb + 1) * 2.45 - 2.26) / 2.26;
        }
        else
        {
            gxb = 0.217218 + 0.012412 * health.t4 - 0.002913 * health.h1 - 0.005687 * health.t6;
            value = ((gxb + 1) * 2.46 - 2.26) / 2.26;
        }
        zhishuMap.put(23,value);
    }

    /**
     * 高血压
     */
    private void calculate24(){
        double gxy;
        double value;

        if (month >= 3 && month <= 5)
        {
            gxy = -0.01767 - 0.00747 * health.tmax5 - 0.0106 * health.tmax6 - 0.02513 * health.t3 - 0.01157 * health.t4 - 0.00192 * health.h2 + 0.01672 * health.p1 - 0.00548 * health.p4 - 0.02507 * health.n;
            value = ((gxy + 1) * 3.85 - 3.63) / 3.63;
        }
        else if (month >= 6 && month <= 8)
        {
            gxy = 0.40773 - 0.01367 * health.tmax2 - 0.01583 * health.t3 + 0.01314 * health.p1;
            value = ((gxy + 1) * 2.88 - 3.63) / 3.63;
        }
        else if (month >= 9 && month <= 11)
        {
            gxy = 1.00925 - 0.0184 * health.tmax1 - 0.01567 * health.tmin1 + 0.00988 * health.t5 - 0.01686 * health.p1 - 0.01074 * health.n - 0.00208 * health.r;
            value = ((gxy + 1) * 3.96 - 3.63) / 3.63;
        }
        else
        {
            gxy = -0.80374 + 0.05652 * health.tmin2 + 0.00506 * health.h1 + 0.01879 * health.p1 - 0.03205 * health.n;
            value = ((gxy + 1) * 3.94 - 3.63) / 3.63;
        }
        zhishuMap.put(24,value);
    }

    /**
     *旅游,恶劣天气的判断
     */
    private void calculate25() throws IOException {
        double dT, dV, Kr, Kw, Khot;
        double value;
        //dT
        if (temperature < 12)
            dT = 12 - temperature;
        else if (temperature > 27)
            dT = temperature - 27;
        else
            dT = 0;
        //dV
        if (windspeed > 3)
            dV = windspeed - 3;
        else
            dV = 0;
        //Kr
        if (stationYbDto.getFPrecipitation() >= 25)
            Kr = 20;
        else if (stationYbDto.getFPrecipitation() > 5)
            Kr = 10;
        else
            Kr = 0;
        //Kw 恶劣天气,如大雾、雷电、冰雹等(天气状况需完善)


         if (stationYbDto.getFState1() >= 4 || stationYbDto.getFState2() >= 4)

            Kw = 5;
        else
            Kw = 0;
        //Khot
        if (stationYbDto.getFTemperatureHigh() >= 35)
            Khot = 20;
        else
            Khot = 0;
        value = 10 - (stationYbDto.getFCloudAll() + zhishuMap.get(7) + 3 * dT + 3 * dV + Kr + Kw + Khot) / 5;
        zhishuMap.put(25,value);
    }

    /**
     * 垂钓指数，等级暂无，设置一级码的idx为特殊值
     */
    private void calculate26(){
        double value;
        int fa, fb, fc, fd;
        //fa


       if (stationYbDto.getFState1() > 4 || stationYbDto.getFState2() > 4)

            fa = 0;
        else if (stationYbDto.getFState1() == 4 || stationYbDto.getFState2() == 4)

            fa = 1;
        else
            fa = 3;
        //fb
        if (stationYbDto.getFTemperatureHigh() < 10)
            fb = 1;
        else if (stationYbDto.getFTemperatureHigh() > 30)
            fb = 3;
        else if (stationYbDto.getFTemperatureHigh() >= 18 && stationYbDto.getFTemperatureHigh() <= 25)
            fb = 8;
        else
            fb = 5;
        //fc
        if (windspeed > 8)
            fc = 0;
        else if (windspeed > 4)
            fc = 1;
        else
            fc = 3;
        //fd
        if (stationYbDto.getFPressure() < 1000)
            fd = 0;
        else if (stationYbDto.getFPressure() < 1010)
            fd = 1;
        else if (stationYbDto.getFPressure() < 1020)
            fd = 2;
        else if (stationYbDto.getFPressure() < 1025)
            fd = 3;
        else
            fd = 4;
        value = fa + fb + fc + fd;//值域[0,15]
        zhishuMap.put(26,value);
        ///////////////////////////////////////////
            /*
            一级码提示语：
            B3：强风犯，鱼乱窜。	index[26].idx = -1(大风，如何界定？)
            C4：暴雨狂，鱼惊慌。	index[26].idx = -2(大雨，如何界定？)
            C5：有雷阵雨或冰雹，不宜出竿。	index[26].idx = -3(雷阵雨、冰雹，天气状况中补充)
            C6：寒潮前出杆有鱼获，寒潮影响后收竿快走。 index[26].idx = -4(寒潮前)|index[26].idx = -5(寒潮后)
            C7：下雾不下雨，雾后再钓鱼。	index[26].idx = -6(有雾且无雨)

            特殊条件的判断，需要设定特定的idx值，并range.xml文件中添加
            另外，暂无对应等级的界值
            */
        ///////////////////////////////////////////
    }

    /**
     * 交通，风的级数对应的风速
     */
    private void calculate27(){
        double value;
        //D=f(A)+f(B)+f(C)+f(D)+f(E)
        int fa, fb, fc, fd, fe;
        //fa

        if (stationYbDto.getFState1() >= 8 || stationYbDto.getFState2() >= 8)

            fa = 3;
        else if (stationYbDto.getFState1() >= 6 || stationYbDto.getFState2() >= 6)

            fa = 2;
        else if (stationYbDto.getFState1() >= 4 || stationYbDto.getFState2() >= 4)

            fa = 1;
        else
            fa = 0;
        //fb
       if (stationYbDto.getFState1() == 3 || stationYbDto.getFState2() == 3)

            fb = 5;
        else
            fb = 0;
        //fc
        if (stationYbDto.getFTemperatureLow() <= 1)
            fc = 5;
        else if (stationYbDto.getFTemperatureLow() <= 4)
            fc = 1;
        else
            fc = 0;
        //fd
        if (stationYbDto.getFTemperatureHigh() >= 35)
            fd = 2;
        else
            fd = 0;
        //fe
        if (windspeed >= 5.5)
            fe = 2;
        else
            fe = 0;

        value = fa + fb + fc + fd + fe;
        zhishuMap.put(27,value);
    }

    /**
     * 用电,计算值和等级标准不能对应
     */
    public void calculate28(){
        double value;
        double x1, x2, x3, x4, lamda;
        x1 = (double)stationYbDto.getFTemperatureHigh();
        x2 = (double)stationYbDto.getFTemperatureLow();
        x3 = (double)wetness;
        //雨天的判断
        if (stationYbDto.getFCloudAll() <= 3)
            x4 = 0.0;
        else if (stationYbDto.getFCloudAll() <= 7)
            x4 = 1.0;
        else
            x4 = 2.0;

        if (stationYbDto.getFState1() >= 4 || stationYbDto.getFState2() >= 4)

            x4 = 3.0;

        //月份的判断
        Calendar calendar = Calendar.getInstance();
        int day = calendar.DAY_OF_WEEK;
        if (month >= 6 && month <= 9)	//夏季
        {
            switch (day)
            {
                case 0: lamda = (double)-196.04; break;
                case 7: lamda = (double)-84.80; break;
                default: lamda = (double)-77.24; break;
            }
            value = (double)(294.883 + 1.910 * x1 + 1.487 * x2 + 3.866 * x3 + 27.534 * x4 + lamda) / 6400.0;
        }
        else if (month >= 10 && month <= 11)  //秋季
        {
            switch (day)
            {
                case 0: lamda = (double)-196.45; break;
                case 7: lamda = (double)-84.98; break;
                default: lamda = (double)-77.41; break;
            }
            LocalDateTime nowTime = LocalDateTime.now();
            LocalDateTime t1 = LocalDateTime.of(nowTime.getYear(),10,1,0,0,0);
            LocalDateTime t2 = LocalDateTime.of(nowTime.getYear(),10,8,0,0,0);
            if (nowTime.isAfter(t1) && nowTime.isBefore(t2))
            {
                lamda = (double)-469.58;
            }
            value = (double)(953.963 + 0.401 * x1 + 5.131 * x3 + 23.100 * x4 + lamda) / 1035.0;
        }
        else if (month >= 3 && month <= 5)  //春季
        {
            switch (day)
            {
                case 0: lamda = (double)-131.62; break;
                case 7: lamda = (double)-56.93; break;
                default: lamda = (double)-51.86; break;
            }
            LocalDateTime nowTime = LocalDateTime.now();
            LocalDateTime t1 = LocalDateTime.of(nowTime.getYear(),5,1,0,0,0);
            LocalDateTime t2 = LocalDateTime.of(nowTime.getYear(),5,8,0,0,0);
            if (nowTime.isAfter(t1) && nowTime.isBefore(t2))
            {
                lamda = (double)-314.59;
            }
            value = (double)(1486.463 - 0.288 * x1 + 0.378 * x3 + lamda) / 1505.0;
        }
        else             //冬季
        {
            switch (day)
            {
                case 0: lamda = (double)-129.47; break;
                case 7: lamda = (double)-56.01; break;
                default: lamda = (double)-51.02; break;
            }
            //元旦
            LocalDateTime nowTime = LocalDateTime.now();
            LocalDateTime t1 = LocalDateTime.of(nowTime.getYear(),1,1,0,0,0);
            LocalDateTime t2 = LocalDateTime.of(nowTime.getYear(),1,4,0,0,0);
            if (nowTime.isAfter(t1) && nowTime.isBefore(t2))
            {
                lamda = (double)-309.44;
                ////////////////////////////////////////
                //春节的判断
                ////////////////////////////////////////
            }
            value = (double)(1028.345 - 1.185 * x1 + 4.872 * x3 + 51.236 * x4 + lamda) / 1350.0;
        }
        zhishuMap.put(28,value);
    }

    /**
     * 火险，需要昨日纪录
     * @throws IOException
     */
    private void calculate29() throws IOException {
        double value =0;

        ApplicationHome applicationHome = new ApplicationHome(FileUtil.class);
        String filepath = applicationHome.getDir().getParentFile().getParentFile().getAbsolutePath() + "\\src\\main\\resources\\file\\zyindex\\城市火险指数.txt";
        FileInputStream inputSteam = new FileInputStream(filepath);
        BufferedReader br = new BufferedReader(new InputStreamReader(inputSteam));

        int season = 0, i = 0;
        double[] c = new double[6];
        String str = "";
        double dT = 0.0;
        int n1 = 0, n10 = 0;//需要存储
        ////////////////////////////////////////
        int pren1 = 0, pren10 = 0;//前一日的n1、n10
        n1 = 14;
        n10 = 2;
        //N1: = pren1 + 1  ;     N10: = pren10 + 1；
        //pren1:到当天为止日降水量≤2mm的连续天数（只要>2mm则记为0）；
        //pren10:到当天为止日降水量≤10mm的连续天数（只要>10mm则记为0）；
        ////////////////////////////////////////
        if (stationYbDto.getFPrecipitation() <= 2)
        {
            n1 = pren1 + 1;
            n10 = pren10 + 1;
        }
        else if (stationYbDto.getFPrecipitation() <= 10)
        {
            n1 = 0;
            n10 = pren10 + 1;
        }
        else
        {
            n1 = 0;
            n10 = 0;
        }

        //C0~C5的系数
        switch (month)
        {
            case 12:
            case 1:
            case 2:
                season = 1; break;
            case 3:
            case 4:
            case 5:
                season = 2; break;
            case 6:
            case 7:
            case 8:
                season = 3; break;
            case 9:
            case 10:
            case 11:
                season = 4; break;
        };
        for (i = 0; i < season; i++)
        {
            str = br.readLine();
        }
        str = str.replace("\t", ",");
        String[] strtemp = str.split(",");
        for (i = 0; i < 6; i++)
        {
            if (strtemp[i] != "")
            {
                c[i] = Double.parseDouble(strtemp[i]);
            }

            //  str = str.Remove(0, 11);
        }

        dT = stationSkDto.getTTemperatureHigh() - stationSkDto.getTTemperatureLow();
        double n10temp;
        double n1temp;
        if (n10 == 0)
        {
            n10temp = 0;
        }
        else
        {
            n10temp = Math.log10(n10);
        }
        if (n1 == 0)
        {
            n1temp = 0;
        }
        else
        {
            n1temp = Math.log10(n1);
        }
        //指数计算
        switch (season)
        {
            case 1:
                value = c[0] + c[1] * (2 - Math.log10(stationYbDto.getFWetnessLow())) + c[2] * (stationYbDto.getFTemperatureHigh() + 2)
                        + c[3] * n10temp + c[4] * n1temp + c[5] * Math.log10(stationYbDto.getFWetnessLow());
                break;
            case 2:
                value = c[0] + c[1] * Math.exp(-0.694 * Math.log(stationYbDto.getFWetnessLow())) + c[2] * dT * dT
                        + c[3] * n10 * n10 + c[4] * Math.exp(0.04828 * n1) + c[5] * Math.log10(stationYbDto.getFWindSpeedHigh());
                break;
            case 3:
                value = c[0] + c[1] * (100 - stationYbDto.getFWetnessLow()) / (stationYbDto.getFWetnessLow() - 17.387) + c[2] * (dT - 1) / (dT + 2.788)
                        + c[3] * n10temp + c[4] * n1temp + c[5] * Math.log10(stationYbDto.getFWindSpeedHigh());
                break;
            case 4:
                value = c[0] + (c[1] * Math.exp(-0.0022 * stationYbDto.getFWetnessLow()) - 0.442) + c[2] * dT * dT
                        + c[3] * n10temp + c[4] * n1 * n1 + c[5] * stationYbDto.getFWindSpeedHigh() * stationYbDto.getFWindSpeedHigh();
                break;
        };
        double d;
//        bool dd = double.TryParse(index[29].idx.ToString(), out d);
//        bool isNu = double.IsNaN(index[29].idx);
//        if (value == - || !dd || isNu)
//        {
//            value = 0;
//        }
        if (Double.isNaN(value) || Double.isInfinite(value)){
            value = 0;
        }
        zhishuMap.put(29,value);
;    }

    /**
     *晨练，需要空气污染气象条件的等级
     */
    private void calculate30(){
        //Sp(晨练指数)=f(x1(天空状况)+x2(风力)+x3(日最低气温)+x4(空气污染气象))
        int x1, x2, x3, x4;

        //x1
        if (stationYbDto.getFState1() >= 6 || stationYbDto.getFState2() >= 6)
            x1 = 5;
       else if (stationYbDto.getFState1() >= 4 || stationYbDto.getFState2() >= 4)
            x1 = 1;
        else
            x1 = 0;
        //x2
        if (windspeed >= 5.5)
            x2 = 3;
        else if (windspeed >= 3.4)
            x2 = 1;
        else
            x2 = 0;
        //x3
        if (stationYbDto.getFTemperatureLow() < 5)
            x3 = 5;
        else if (stationYbDto.getFTemperatureLow() <= 10)
            x3 = 1;
        else
            x3 = 0;
        ////////////////////////////////////////
        //x4,空气污染气象条件
        x4 = 0;
        //F(x4)=0, 等级≤3；
        //4,      =4；
        //5，     =5；
        ////////////////////////////////////////

        double value = x1 + x2 + x3 + x4;
        zhishuMap.put(30,value);
    }

    /**
     * 关节炎
     */
    private void calculate0(){
        zhishuMap.put(0,-10000.0);
    }

}
